<template>
  <div class="container">
    <router-view></router-view>
    <div class="index">
     <Header :user="userInfo" />
      <div class="main">
        <div class="main-top">
          <div class="con-menu" @click="lecture()">
            <div class="menu-img">
              <img src="../../static/img/shouke.png" alt="">
            </div>
            <div class="menu-item">
              授课
            </div>
          </div>
          <div class="con-menu mr0"  @click="train()">
            <div class="menu-img">
              <img src="../../static/img/peixun.png" alt="">
            </div>
            <div class="menu-item">
              培训
            </div>
          </div>
        </div>
        <div class="main-bottom"  >
          <div class="con-menu"  @click="message()">

            <div class="menu-img">
              <img class="dot-red" src="../../static/img/dot-red.png"  v-if="status != 0 ">
              <img src="../../static/img/xiaoxi.png" alt="">
            </div>
            <div class="menu-item">
              消息
            </div>
          </div>
          <div class="con-menu2"   @click="my()">
            <div class="menu-img">
              <img src="../../static/img/wode.png" alt="">
            </div>
            <div class="menu-item">
              我的
            </div>
          </div>
          <div class="con-menu3"  @click="feedback()">
            <div class="menu-img">
              <img src="../../static/img/fankui.png" alt="">
            </div>
            <div class="menu-item">
              反馈
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import Header from '../components/header.vue';
import Copyright from '../components/copyright.vue';
export default {
  data() {
    return {
      status: 0,
      userInfo:JSON.parse(localStorage.getItem('userInfo' ))
    };
  },
  created() {
    this.checkAuth();
    this.getmessageStatus();
  },
  methods: {
    checkAuth(){
      let userAuth = JSON.parse(localStorage.getItem('userAuth'));
      let jump_url = userAuth.jump_path;
      console.log("jump_url:" + jump_url)
      if(jump_url != this.$route.path ){
        this.$router.push(jump_url);
      }
    },

    getmessageStatus() {
      this.$api('message.getmessageStatus', { token: localStorage.getItem('token') }).then(res => {
        this.status = res.data.status;
      });
    },
    lecture(){
      this.$router.push("/lecture")
    },
    train(){
      this.$router.push("/train")
    },
    message(){
      this.$router.push("/msglist")
    },
    my(){
      this.$router.push("/profile")
    },
    feedback(){
      this.$router.push("/feedback")
    }
  },
  components:{Header,Copyright}
};
</script>

<style lang="scss" scoped>

</style>
